package com.jesper.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jesper.mapper.OrderMapper;
import com.jesper.model.Order;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService extends ServiceImpl<OrderMapper, Order> {

    public Page<Order> orderQuery(int page, int pageSize, Order order) {

        QueryWrapper<Order> orderWrapper = new QueryWrapper<>();
        Page mPage = new Page<>(page, pageSize);

        orderWrapper.eq(order.getStatus() != null, "status", order.getStatus());
        orderWrapper.eq(order.getPaymentType() != null, "payment_type", order.getPaymentType());
//        orderWrapper.isNotNull("minOrderTime");
//        orderWrapper.isNotNull("maxOrderTime");


        return this.baseMapper.selectPage(mPage, orderWrapper);

    }

    public List<Order> reFound(Order order) {
        QueryWrapper<Order> orderQueryWrapper = new QueryWrapper<>();
        orderQueryWrapper.eq(order.getStatus() != null, "status", order.getStatus());
        return this.baseMapper.listRefund(order);
    }

    public List<Order> list() {
        QueryWrapper<Order> orderWrapper = new QueryWrapper<>();
        List<Order> list = baseMapper.selectList(orderWrapper);
        return list;
    }

    public Long selectCurPayment() {
        return this.baseMapper.selectCurPayment();
    }

    public Integer selectCurRefundOrder() {
        return this.baseMapper.selectCurRefundOrder();
    }

    public Long selectLastPayment() {
        return this.baseMapper.selectLastPayment();
    }

    public Integer selectCurOrderNum() {
        return this.baseMapper.selectCurOrderNum();
    }

    public Integer selectLastOrderNum() {
        return this.baseMapper.selectLastOrderNum();
    }

    public Integer selectLastRefundOrder() {
        return this.baseMapper.selectLastRefundOrder();
    }

    public Integer selectDayOrderSum(Order order) {
        return this.baseMapper.selectDayOrderSum(order);
    }
}
